package com.huadao.cart_ccs.data.source.websocket;

import android.net.Uri;
import android.util.Log;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;
import java.net.URISyntaxException;

public class SimpleWebSocket extends WebSocketClient {

    private static final String TAG = "WebSocket";

//    public static void main(String[] args) throws URISyntaxException {
//        WebSocketClient client = new SimpleWebSocket("ws://121.40.165.18:8800");
//        client.connect();
//    }

    public SimpleWebSocket(String serverUri) throws URISyntaxException {
        super(new URI(serverUri));
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
        Log.i(TAG,"onOpen");
    }

    @Override
    public void onMessage(String message) {
        Log.i(TAG,"onMessage");
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        Log.i(TAG,"onClose");
    }

    @Override
    public void onError(Exception ex) {
        Log.i(TAG,"onError");
    }
}
